<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        // let arr = ['a', "b", "c"]
        // arr.forEach((item, index) => {
        //     console.log('item:' + item + ",index:" + index)
        // });
        // for (let key in arr) {
        //     if (Object.hasOwnProperty.call(arr, key)) {
        //         const element = arr[key];
        //         console.log(element,key)
        //     }
        // }
        // for (const item of arr) {
        //     console.log(item)
        // }
        // map和forEach都不影响原数组，map会返回一个数组，forEach返回值为undefined，
        // 循环中return和break无法打断
        let arr = [1, 2, 3, 4]
        let foreachArr = arr.forEach(item => {
            item = item + 1
            console.log(item)
        })
        let mapArr = arr.map(item => {
            item = item + 1
            console.log(item)
            return item
        })
        console.log('arr', arr)
        console.log('foreachArr', foreachArr)
        console.log('mapArr', mapArr)
    </script>
</head>

<body>

</body>

</html>